<?php

//
//  Copyright (C) 2004-2006  Autodesk, Inc.
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of version 2.1 of the GNU Lesser
//  General Public License as published by the Free Software Foundation.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//

?>

<?php
require_once("config.php");
require_once("utils.php");
require_once(ROOT_DIR_CLASES.'/cCliente.php'); 
require_once(ROOT_DIR_CLASES.'/Contacto.php');
require_once 'JSON.php';

class QueryContacto
{
	private $args = null;
	
	function __construct($args)
	{
		$this->args = $args;
	}

	function Execute()
	{
		$result = array();
		$cta = $this->args['CUENTA'];
		$objetivo = $this->args['OBJETIVO'];
        //--------------------------------------	
   		$datosContacto = BykomCliente::Consulta_Datos_Contacto_Avl($cta, $objetivo);
        for($i = 0;  $i < $datosContacto->cantidad(); $i++ ) {
			$contacto = new Contacto();
			$contacto->id = $datosContacto->campo('id',0);
			$contacto->cuentaFk = $datosContacto->campo('cuentaFk',0);
			$contacto->objetivo = $datosContacto->campo('objetivo',0);
			$contacto->nomyapel = $datosContacto->campo('nomyapel',0);
			$contacto->tipodoc = $datosContacto->campo('tipodoc',0);
			$contacto->nrodoc = $datosContacto->campo('nrodoc',0);
			$contacto->direccion = $datosContacto->campo('direccion',0);
			$contacto->telefono1 = $datosContacto->campo('telefono1',0);
			$contacto->telefono2 = $datosContacto->campo('telefono2',0);
			$contacto->email = $datosContacto->campo('email',0);
			$contacto->observaciones = $datosContacto->campo('observaciones',0);				
        	array_push($result, $contacto);
			}	
		return $result;
	}
}
?>